
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of pagination
 *
 * @author IT
 */
class pagination extends connection {
     function phan_trang($data)
    {
       $perpage = 2;
       $value = ceil($data/$perpage);
       if(isset($_GET['page']))
          $page = $_GET['page'];
       else {
          $page = 1;
       }
       //first
       $first = 1;
       echo '<li><a href ="index.php?page='.$first.'" class ="'.'first'.'">'.'First'.'</a></li>';
       
       //previous
       if($page > 1)
       {
           $previous = $page - 1;
           echo '<li><a href="index.php?page='.$previous.'" class ="'.'previous'.'">'.'Previous'.'</a></li>';
       }
       //page
       for($i = 1; $i <= $value;$i++)
       {
           if($page == $i)
               echo '<li><a><b>'.$i.'</b></a></b>';
           else
               echo '<li><a href="index.php?page='.$i.'">'.$i.'</a></li>';
       }
       
       //next
       if($page < $value)
       {
           $next = $page + 1;
           echo '<li><a href="index.php?page='.$next.'" class ="'.'next'.'">'.'Next'.'</a></li>';
       }
       
      //last
       for($j = 1; $j < $value;$j++)
       {
            $last = $j + 1 ;
            if($last <= $value )
                $last1 = '<li><a  href = "index.php?page='.$last.'" class="'.'last'.'">'.'Last'.'</a></li>';
       }
       echo $last1;
    }
}